﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
using WPFChat.Model;
using WPFChat.ViewModel;

namespace WPFChat.Converter
{
    public class StateToColorConverter : IValueConverter
    {
        public Brush OnlineBrush  { get; set; }
        public Brush OfflineBrush { get; set; }
        public Brush BusyBrush    { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is StateViewModel)
            {
                var viewModel = value as StateViewModel;
                var state = (State) viewModel.ContainedObject;

                switch (state)
                {
                    case State.Online:
                        return OnlineBrush;
                    case State.Busy:
                        return BusyBrush;
                    case State.Offline:
                        return OfflineBrush;
                }    
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
